class_name BigOperation extends Node

var operationManager = null
var big:Big			#要出大的大子

func init(om:OperationManager):
	self.operationManager = om
	return self

# 出大，周围point开启监听 
func preparation_bornBig():
	operationManager.arr_listeningPoints.clear()
	var point = operationManager.selectedPoint
	var arrAroundPoints = GameUtils.getArrPointsAround(point)
	for p in arrAroundPoints:
		if p.is_view:
			if [Terrain.shan,Terrain.shui,Terrain.jing].has(p.real_terrain):
				continue
			if p.small != null:
				continue
			if p.big != null:		#有大子
				if p.big.player.is_me:	#是自己的
					continue
				if !p.big.arr_states.has(BigStateType.HIDE):	#敌人大子没有潜行
					continue
		operationManager.arr_listeningPoints.append(p)
	GameUtils.neatAnimation()
	big = point.big
	big.detailHide()

# 移动，周围point开启监听 
func preparation_bigMove():
	operationManager.arr_listeningPoints.clear()
	var point = operationManager.selectedPoint
	big = point.big
	var arrAroundPoints = GameUtils.getArrPointsAround(point)
	for p in arrAroundPoints:
		if p.is_view:
			if [Terrain.shan,Terrain.jing].has(p.real_terrain):
				continue
			if Terrain.shui == p.real_terrain && !big.arr_states.has(BigStateType.WAVERIDER):
				continue
			if p.small != null:
				continue
			if p.big != null:		#有大子
				if p.big.player.is_me:	#是自己的
					continue
				if !p.big.arr_states.has(BigStateType.HIDE):	#敌人大子没有潜行
					continue
		operationManager.arr_listeningPoints.append(p)
	GameUtils.neatAnimation()
	big.detailHide()

# 攻击，周围point开启监听 
func preparation_bigAttack():
	operationManager.arr_listeningPoints.clear()
	var point = operationManager.selectedPoint
	var arrAroundPoints = GameUtils.getArrPointsAround(point)
	for p in arrAroundPoints:
		if p.is_view:
			if [Terrain.shan,Terrain.jing].has(p.real_terrain):
				continue
			if Terrain.shui == p.real_terrain && !point.big.arr_states.has(BigStateType.WAVERIDER):
				continue
			if p.small != null && p.small.player.is_me:
				continue
			if p.big != null:
				if p.big.player.is_me:
					continue
		operationManager.arr_listeningPoints.append(p)
	GameUtils.neatAnimation()
	big = point.big
	big.detailHide()

func bigBornBig(point:Point):
	WebSocketManager.sendObj(true,"bigBornBig",{"start":big.point.id,"end":point.id})
	operationManager.cancel()

func bigMove(point:Point):
	WebSocketManager.sendObj(true,"bigMove",{"start":big.point.id,"end":point.id})
	operationManager.cancel()

func bigAttack(point:Point):
	WebSocketManager.sendObj(true,"bigAttack",{"start":big.point.id,"end":point.id})
	operationManager.cancel()
